<template>
	<view class="page_box">
		<view class="head_box ">
			<yy-custom bgColor="bg-gradual-blue" v-if="0">
				<block slot="backText">返回</block>
				<block slot="content">导航栏</block>
			</yy-custom>
		</view>

		<view class="content_box">
			<view class="head flex align-center justify-center flex-direction">
				<text class="text-bold " style="font-size: 57rpx;">{{ totle }}</text>
				<text class="f24 margin-top-sm text-black">当前积分</text>
			</view>
			<view class=" flex padding  justify-around f30 bg-white margin-bottom-sm">
				<text
					class="  flex flex-direction align-center"
					@click="flg(1)"
					:class="sts == 1 ? 'style' : ''"
				>
					全部
				</text>
				<text
					class=" flex  flex-direction align-center"
					@click="flg(2)"
					:class="sts == 2 ? 'style' : ''"
				>
					流入
				</text>
				<text
					class=" flex  flex-direction align-center"
					@click="flg(3)"
					:class="sts == 3 ? 'style' : ''"
				>
					流出
				</text>
			</view>

			<scroll-view scroll-y="true" @scrolltolower="lower" class="scroll">
				<view class="list  padding-lr  bg-white ">
					<view
						class="flex flex justify-between padding-tb-sm  solid-bottom"
						v-for="(item, index) in data"
						:key="index"
					>
						<view class="flex flex-direction justify-center ">
							<text class="f28">{{ item.type == 0 ? '收入' : '支出' }}</text>
							<text class="f26 text-gray margin-top-xs">{{ item.modifyDt }}</text>
						</view>
						<view class="flex align-center">
							<text class="text-red f30 text-bold" v-if="item.type == 0">+{{ item.num }}</text>
							<text class="text-black f30 text-bold" v-else>-{{ item.num }}</text>
						</view>
					</view>
				</view>
			</scroll-view>
		</view>
		<view class="foot_box"></view>
		<!-- 登录提示 -->
		<yy-login v-if="false"></yy-login>
		<!-- 加载提示 -->
		<yy-loading text="加载中.." mask="true" click="true" ref="loading"></yy-loading>
		<!-- 信息提示-->
		<u-toast ref="uToast" />
	</view>
</template>

<script>
export default {
	components: {},
	data() {
		return { sts: 1, size: 10, current: 1, data: [], totle: '' };
	},
	onShow() {
		this.earnPoints();
	},
	onLoad(e) {},
	methods: {
		jump(url) {
			console.log('url: ', url);
			uni.navigateTo({
				url
			});
		},
		flg(e) {
			this.sts = e;
			this.data = []
			switch (e) {
				case 1:
					this.earnPoints('');
					break;
				case 2:
					this.earnPoints(0);
					break;
				case 3:
					this.earnPoints(1);
					break;
				default:
					break;
			}
		},
		async lower(){
			if (this.data.length==0) {
				return this.$refs.uToast.show({ title: '暂无更多积分记录',type: 'error' });
			} else {
				this.current++
				this.earnPoints(this.sts)
			}
		},
		async earnPoints(type = '') {
			let obj = {
				userId: uni.getStorageSync('data').id,
				size: this.size,
				current: this.current,
				type
			};
			const res = await this.$u.get('score/myScore', obj, {});
			this.data = [...this.data,...res.data.page.records];
			this.totle = res.data.totle;

			console.log('this.data >>  ', this.data);
		}
	}
};
</script>

<style lang="scss" scoped>
.page_box {
	
	margin-top: -5rpx;
	background-color: #f7f7f7;
	.scroll {
		height: calc(100vh - 226px);
		// background-color: red;
		
	}
	.content_box {
		.head {
			width: 100vw;
			height: 224rpx;
			background: #92b9b7;
		}

		.style::after {
			content: '';
			width: 50rpx;
			height: 6rpx;
			background: #fbb03b;
			border-radius: 3rpx;
			margin-top: 15rpx;
		}
		.style {
			font-weight: 600;
		}
	}
}
</style>
